import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    money: 100
  },
  getters: {
    newMoney(state) {
      return state.money + '元'
    }
  },
  mutations: {
    setMoney(state, value) {
      state.money = value
    }
  },
  actions: {
    lazyMoney(ctx, value) {
      setTimeout(() => {
        ctx.commit('setMoney', value)
      }, 2000)
    }
  },
  modules: {}
})
